######################################################################
# Bit Serial PE Modelsim do file
# Stephen West, James Carroll
# Fall 2008, ECEn 620
######################################################################

quit -sim
vcom PE.vhd
vcom *.vhd

vsim PE

add wave clk
add wave -color blue lsb_in
add wave -group config config_ctrl_in config_data(15) index_data code/index_data code/index code/CodeBook(15) code/ns code/counter_word
add wave -group default_values error_in index_in
add wave -color "steel blue" code/cs
add wave -color orange pixels_in
add wave -color red sub_out
add wave -color red sub_lsb
add wave -color "indian red" abs_out
add wave -color "indian red" abs_lsb
add wave -color "sienna" sum_out
add wave -color "sienna" sum_lsb
add wave error_delay
add wave lesser_error
add wave this_is_lesser
#add wave lesser/*
add wave index_in_delay
add wave index_this_delay
add wave -group output pixels_out error_out index_out lsb_out


# Drive the clock
force clk 1,0 10ns -r 20ns
run 2ns
force lsb_in 0

force config_ctrl_in 0 
force index_data 0
force config_data 0000000000000000
run 40 ns

force config_ctrl_in 1,0 20ns
force index_data 1,0 20ns

# CodeBook values
force config_data 1010101010101010
run 20 ns
force config_data 1100110011001100
run 20 ns
force config_data 1111000011110000
run 20 ns
force config_data 1111111100000000
run 20 ns
force config_data 0000000000000000
run 20 ns
force config_data 0000000000000000
run 20 ns
force config_data 0000000000000000
run 20 ns
force config_data 0000000000000000
run 20 ns
force config_data 0000000000000000
run 20 ns
force config_data 0000000000000000
run 20 ns
force config_data 0000000000000000
run 20 ns

#extra config cycles (useless data; values chosen to ensure they are not used)
force config_data 1100111111111111
run 20 ns 
force config_data 1101000000000001
run 20 ns
force config_data 1100111111111111
run 20 ns 
force config_data 1101000000000001
run 20 ns


force lsb_in 1,0 20ns -r 240ns

# Here, the error_in will be *less* than the calculated error
force error_in 0
force index_in 1
force pixels_in 0000000000000000
run 240 ns

# Here, the error_in will be *greater* than the calculated error
force error_in 1,0 220ns
force pixels_in 1111111111111111,0000000000000000 40ns
run 240 ns

# Here, the error_in will be *equal to* than the calculated error
force error_in 0 120ns
run 120 ns
force error_in 1,0 20ns
run 20 ns
force pixels_in 1111111111111111,0000000000000000 60ns
run 100 ns

# Unused
# force error_in 1,0 160ns
# force pixels_in 1111111111111111,0000000000000000 80ns
# run 240 ns
# 
# force error_in 1,0 140ns
# force pixels_in 1111111111111111,0000000000000000 100ns

run 240 ns
run 240 ns
run 240 ns

# All done, go home!
